//
//  JCClubInfoWeekPlanCircleCell.m
//  SquashSpark
//
//  Created by 郭吉成 on 2017/11/22.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import "JCClubInfoWeekPlanCircleCell.h"
#import "JCClubModel.h"

@interface JCClubInfoWeekPlanCircleCell()

@property (weak, nonatomic) IBOutlet UILabel *leftValueLabel;
@property (weak, nonatomic) IBOutlet UILabel *centerValueLabel;
@property (weak, nonatomic) IBOutlet UILabel *rightValueLabel;

@property (weak, nonatomic) IBOutlet UILabel *leftTextLabel;
@property (weak, nonatomic) IBOutlet UILabel *centerTextLabel;
@property (weak, nonatomic) IBOutlet UILabel *rightTextLabel;

@property (weak, nonatomic) IBOutlet UILabel *textInfoLabel;

@property (weak, nonatomic) IBOutlet UILabel *bottomLeftValueLabel;
@property (weak, nonatomic) IBOutlet UILabel *bottomLeftTextLabel;
@property (weak, nonatomic) IBOutlet UILabel *bottomRightValueLabel;
@property (weak, nonatomic) IBOutlet UILabel *bottomRightTextLabel;

@end

@implementation JCClubInfoWeekPlanCircleCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)drawRect:(CGRect)rect{
    for (NSInteger i = 0; i < 3; i++) {
        CAShapeLayer *layer = [CAShapeLayer new];
        layer.fillColor = nil;
        layer.frame = _leftValueLabel.bounds;
        
        CGPoint center = CGPointMake(CGRectGetWidth(_leftValueLabel.bounds) / 2, CGRectGetHeight(_leftValueLabel.bounds) / 2);
        UIBezierPath *path =
        [UIBezierPath bezierPathWithArcCenter:center
                                       radius:(_leftValueLabel.bounds.size.width)/ 2 * 0.7
                                   startAngle:0.25 * M_PI
                                     endAngle:0.75 * M_PI
                                    clockwise:NO];;
        layer.path = path.CGPath;
        layer.lineWidth = 5;
        if (i == 0) {
            layer.strokeColor = [UIColor colorWithHex:0xd955e5].CGColor;
            [_leftValueLabel.layer addSublayer:layer];
        }else if (i == 1) {
            layer.strokeColor = [UIColor colorWithHex:0x55a4e5].CGColor;
            [_centerValueLabel.layer addSublayer:layer];
        }else if (i == 2) {
            layer.strokeColor = [UIColor colorWithHex:0x0feb8b].CGColor;
            [_rightValueLabel.layer addSublayer:layer];
        }
    }
}

- (void)setWatchType:(WatchClubType)watchType{
    _watchType = watchType;
    if (watchType == WatchClubTypeApplyForAmission) {
        _bottomLeftValueLabel.hidden = YES;;
        _bottomLeftTextLabel.hidden = YES;
        _bottomRightValueLabel.hidden = YES;
        _bottomRightTextLabel.hidden = YES;
    }else if (watchType == WatchClubTypeOtherMember){
        _bottomLeftValueLabel.hidden = YES;;
        _bottomLeftTextLabel.hidden = YES;
        _bottomRightValueLabel.hidden = YES;
        _bottomRightTextLabel.hidden = YES;
    }else if (watchType == WatchClubTypeMyMemberGeneral){
        _bottomLeftValueLabel.hidden = YES;;
        _bottomLeftTextLabel.hidden = YES;
        _bottomRightValueLabel.hidden = YES;
        _bottomRightTextLabel.hidden = YES;
    }else if (watchType == WatchClubTypeMyMemberAdmin){
        _bottomLeftValueLabel.hidden = YES;;
        _bottomLeftTextLabel.hidden = YES;
        _bottomRightValueLabel.hidden = YES;
        _bottomRightTextLabel.hidden = YES;
    }
}

- (void)setSportItem:(JCClubInfoSportItem *)sportItem{
    _sportItem = sportItem;
    _leftValueLabel.text = sportItem.activeDays;
    _centerValueLabel.text = sportItem.swings;
    if (sportItem.duration.integerValue < 60) {
        _rightValueLabel.text = [NSString stringWithFormat:@"%ldmin",sportItem.duration.integerValue%60];
    }else{
        _rightValueLabel.text = [NSString stringWithFormat:@"%ldh %ldm",sportItem.duration.integerValue/60,sportItem.duration.integerValue%60];
    }
}

- (void)setIsWatchMember:(BOOL)isWatchMember{
    _isWatchMember = isWatchMember;
    _bottomLeftValueLabel.hidden = !isWatchMember;
    _bottomLeftTextLabel.hidden = !isWatchMember;
    _bottomRightValueLabel.hidden = !isWatchMember;
    _bottomRightTextLabel.hidden = !isWatchMember;
    
}
    
    - (void)setIndexPath:(NSIndexPath *)indexPath{
        _indexPath = indexPath;
        if(indexPath.row == 0){
            _textInfoLabel.text = @"Are you satisfied with your sports data last week? Be sure to remember to finish the club's sports plan to get the Sports Weekly";
        }else if (indexPath.row == 1){
            _textInfoLabel.text = @"The movement plan this week include: active days, swing number, exercise time, finish it! You can see your detailed weekly Sports Weekly";
        }else if (indexPath.row == 2){
            _textInfoLabel.text = @"Finish the sports plan and make more efforts to improve yourself. Squash Spark can help you manage sports and offer more advice";
        }
    }

@end
